//
//  CLPageTopView.m
//  CLBrowser
//
//  Created by 梁慧聪 on 2022/5/15.
//

#import "CLPageTopView.h"
@interface CLPageTopView()
@property (nonatomic,strong) UIButton *backBtn;

@end
@implementation CLPageTopView

-(instancetype)initWithFrame:(CGRect)frame {
    if(self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor darkGrayColor];
        [self setupUI];
    }
    return self;
}
- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.equalTo(self).offset(10);
        make.size.mas_equalTo(CGSizeMake(30, 30));
    }];
}
- (void)setupUI {
    [self addSubview:self.backBtn];
}

- (void)back {
    if([self.delegate respondsToSelector:@selector(backInDCPageTopView:)]) {
        [self.delegate backInDCPageTopView:self];
    }
}
- (UIButton *)backBtn {
    if(_backBtn == nil) {
        _backBtn = [[UIButton alloc]init];
        [_backBtn setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
        [_backBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    }
    return _backBtn;
}

@end
